package com.taotao.manage.controller.api;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.taotao.common.pojo.ItemCatResult;
import com.taotao.manage.service.ItemCatService;

@Controller
@RequestMapping(value="api/item/cat")
public class ApiItemCatController {
	
	@Autowired
	private ItemCatService itemCatService;
	
	
	@RequestMapping(method=RequestMethod.GET)
	public ResponseEntity<ItemCatResult> queryItemCatResult(){
		try {
			ItemCatResult itemCatResult = itemCatService.queryItemCatResult();
			if (itemCatResult == null) {
				return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
			}
				return ResponseEntity.ok(itemCatResult);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
	}
}
